#define  _CRT_SECURE_NO_WARNINGS

#include<iostream>
using namespace std;

//typedef long long ll;
//
//ll gcd(ll a, ll b)
//{
//	return b == 0 ? a : gcd(b, a % b);
//}
//
//ll lcm(ll a, ll b)
//{
//	return a * b / gcd(a, b);
//}
//
//void solve()
//{
//	ll a = 0, b = 0;
//	cin >> a >> b;
//	cout << lcm(a, b);
//}

//void solve()
//{
//
//}
//
//int main()
//{
//	solve();
//	return 0;
//}

#include <queue>
#include<vector>
class Solution {
public:
    int MLS(vector<int>& arr) {
        if (arr.size() == 0)
        {
            return 0;
        }
        sort(arr.begin(), arr.end());
        int dst = 0, cur = dst + 1;
        int maxlen = 1;
        priority_queue<int> pq;
        while (cur < arr.size())
        {
            if (arr[dst] + 1 == arr[cur])
            {
                maxlen++;
            }

            if (arr[dst] + 1 != arr[cur])
            {
                pq.push(maxlen);
                maxlen = 1;
            }
            dst++;
            cur++;

            if (cur >= arr.size())
            {
                pq.push(maxlen);
            }
        }

        return pq.top();
    }
};

int main()
{
    vector<int> v = { 3,5,6,7,8,9,10,1 };
    //vector<int> v = {1,1,1};
    cout << Solution().MLS(v);
    return 0;
}